<template>
	<div class="header" v-loading="loading">
		<div class="header__bg" v-bind:style="{ 'background-image': 'url(' + userInfo.bgimg + ')' }"></div>
		<div class="header-wrap">
			<a class="back iconfont icon-fanhui" @click="goBack"></a>
			<div class="header__userinfo">
				<div class="header__userinfo--func">
					<div class="zan"><i class="iconfont icon-praise"></i>赞</div>
					<div class="img">
						<img :src="userInfo.img" alt="" />
					</div>
					<div class="follow">+关注</div>
				</div>
				<div class="header__userinfo--name">{{userInfo.name}}<i class="iconfont icon-chongwu"></i></div>
				<div class="header__userinfo--major">{{userInfo.college}}</div>
			</div>
			<div class="header__attr">
				<div class="header__attr--item">
					<strong>粉丝数量</strong>
					<div class="num">{{userInfo.fans}}</div>
				</div>
				<div class="header__attr--item">
					<strong>获赞数</strong>
					<div class="num">{{userInfo.zan}}</div>
				</div>
				<div class="header__attr--item">
					<strong>级别</strong>
					<div class="num">{{userInfo.level}}</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import { fetchUserInfo } from "../../../../api/api.js";
	export default {
		created() {
			this.getUserInfo();
		},
		data() {
			return {
				loading: true,
				userInfo: {}
			}
		},
		methods: {
			goBack() {
				this.$router.go(-1);
			},
			getUserInfo() {
				this.loading = true;
				fetchUserInfo({id: 1}).then( res => {
					this.loading = false;
					this.userInfo = res.data.result.user;
				} ).catch( (err) => {
					alert(err);
					console.log(err);
				} );
			}
		}
	}
</script>

<style lang="scss" scoped>
	.header {
		width: 100%;
		height: rem(200);
		position: relative;
		
	}
	.header__bg {
		width: 100%;
		height: 100%;
		/*background-image: url("/static/img/pic3.jpg");*/
		background-size: 100% 100%;
		filter: blur(8px);
	}
	.header-wrap {
		padding: $com-padding-lr-base;
		width: 100%;
		height: 100%;
		position: absolute;
		top: 0;
		left: 0;
		display: flex;
		flex-direction: column;
		.back {
			color: #f2f2f2;
		}
	}
	.header__userinfo {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-around;
	}
	.header__userinfo--func {
		display: flex;
		align-items: center;
		font-size: $font-xs;
		.zan {
			padding: rem(1) rem(10);
			color: #fff;
		}
		.img {
			margin: 0 rem(20);
			@include round-header-lg;
		}
		.follow {
			padding: rem(1) rem(10);
			border: 1px solid #fff;
			color: #fff;
		}
	}
	.header__userinfo--name {
		color: $gray-lighter;
		font-size: $font-sm;
		i {
			margin-left: rem(4);
			font-size: $font-sm;
			color: #2cf;
		}
	}
	.header__userinfo--major {
		color: #cfcfcf;
		font-size: $font-xs;
	}
	.header__attr {
		display: flex;
		align-items: center;
		justify-content: space-around;
		text-align: center;
		font-size: $font-sm;
		color: $gray-lighter;
		height: 50px;
		border-top: 1px solid #ccc;
		.num {
			font-size: $font-xs;
			margin-top: rem(2);
			color: $gray-lighter;
		}
	}
	.header__attr--item {
		margin-top: rem(7);
	}
</style>